﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="newfile.aspx.cs" Inherits="Mocola.Net.Web.newfile" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>CsLand Ams v1.0 - 中新置地档案管理系统</title>
    <meta name="description" content="CsLand Ams v1.0 - 中新置地档案管理系统" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <link rel="stylesheet" href="css/content.css" type="text/css" />
    <link rel="stylesheet" href="css/ui.css" type="text/css" />
    <link rel="stylesheet" href="css/sys.css" type="text/css" />
    <link rel="stylesheet" href="css/table.css" type="text/css" />
    <link rel="stylesheet" href="scripts/formcheck/theme/classic/formcheck.css" type="text/css" media="screen" />
    <!--[if IE]>
	    <script type="text/javascript" src="scripts/excanvas-compressed.js"></script>	
	    <style type="text/css"> html{ height: 100%; overflow: auto; } </style>	
    <![endif]-->

    <script type="text/javascript" src="scripts/mootools-1.2-core.js"></script>
    <script type="text/javascript" src="scripts/mootools-1.2-more.js"></script>
    <script type="text/javascript" src="scripts/mocha.js"></script>
    <script type="text/javascript" src="scripts/mocola-funs.js"></script>
    <script type="text/javascript" src="scripts/formcheck/lang/cn.js"> </script>
    <script type="text/javascript" src="scripts/formcheck/formcheck.js"> </script>

</head>
<body style="padding: 5px;">
    <form id="frmNewFile" action="javascript:submitForm()">
    <input type="hidden" id="hidTid" name="Tid" />
    <input type="hidden" id="hidEid" name="Eid" />
    <table class="mytable" cellspacing="0" summary="菜单栏" style="width: 100%">
        <tr>
            <th scope="row" class="specalt">
                <input id="btnSave1" type="submit" value="保存文件" class="btnzc" style="width: 100px" />
                <input id="btnBack" type="button" value="返回列表" class="btnzc" style="width: 100px"
                    onclick="back()" />
            </th>
        </tr>
    </table>
    <table class="mytable" cellspacing="0" summary="新增文件表单" style="width: 100%; margin-top: 5px;">
        <tr>
            <th scope="row" class="spec">
                <div class="title1">
                    填写文件信息：</div>
                <div class="frmline1">
                    <label class="label2">
                        1. 文件名称：</label>
                    <input id="txtMingCheng" type="text" class="inputbox validate['required']" name="MingCheng" />
                </div>
                <div class="frmline1">
                    <label class="label2">
                        2. 文件编号：</label>
                    文件号：<input id="txtWenJianHao" name="WenJianHao" type="text" class="inputbox" style="width: 100px;" />
                    申请号：<input id="txtShenQingHao" name="ShenQingHao" type="text" class="inputbox" style="width: 100px;" />
                    决定号：<input id="txtJueDingHao" name="JueDingHao" type="text" class="inputbox" style="width: 100px;" />
                </div>
                <div class="frmline1">
                    <label class="label2">
                        3. 发文日期：</label>
                    <input id="txtFaWenRiQi_Nian" name="FaWenRiQi_Nian" type="text" class="inputbox validate['digit[2009,3000]']"
                        value="" style="width: 80px;" />年<input type="text" class="inputbox validate['digit[1,12]']"
                            value="" style="width: 50px;" id="txtFaWenRiQi_Yue" name="FaWenRiQi_Yue" />月<input
                                type="text" class="inputbox validate['digit[1,31]']" value="" style="width: 30px;"
                                id="txtFaWenRiQi_Ri" name="FaWenRiQi_Ri" />日
                </div>
                <div class="frmline1">
                    <label class="label2">
                        4. 接收日期：</label>
                    <input id="txtJieShouRiQi_Nian" name="JieShouRiQi_Nian" type="text" class="inputbox validate['digit[2009,3000]']"
                        value="" style="width: 80px;" />年<input type="text" class="inputbox validate['digit[1,12]']"
                            value="" style="width: 50px;" id="txtJieShouRiQi_Yue" name="JieShouRiQi_Yue" />月<input
                                type="text" class="inputbox validate['digit[1,31]']" value="" style="width: 30px;"
                                id="txtJieShouRiQi_Ri" name="JieShouRiQi_Ri" />日
                </div>
                <div class="frmline1">
                    <label class="label2">
                        5. 发文单位：</label>
                    <textarea class="inputbox" style="width: 450px; height: 80px" id="txtFaWenDanWei" name="FaWenDanWei"></textarea>
                </div>
                <div class="frmline1">
                    <label class="label2">
                        6. 数量：</label>
                    <input id="txtShuLiang" type="text" class="inputbox" name="ShuLiang" />
                </div>
                <div class="frmline1">
                    <label class="label2">
                        7. 载体/材质：</label>
                    <select style="width: 100px" id="selZaiTi" name="ZaiTi">
                        <option value="0">纸质</option>
                        <option value="1">电子档</option>
                        <option value="2">光盘</option>
                    </select>
                    /
                    <select style="width: 100px" id="selCaiZhi" name="CaiZhi">
                        <option value="0">文档</option>
                        <option value="1">照片</option>
                        <option value="2">证照</option>
                        <option value="3">图片</option>
                    </select></div>
                <div class="frmline1">
                    <label class="label2">
                        8. 发起部门：</label>
                    选择部门
                </div>
                <div class="frmline1">
                    <label class="label2">
                        9. 移交人：</label>
                    选择移交人
                </div>
                <div class="frmline1">
                    <label class="label2">
                        10. 密级：</label>
                    <select style="width: 100px" id="selMiJi" name="MiJi">
                        <option value="0">公开</option>
                        <option value="1">限制</option>
                        <option value="2">秘密</option>
                    </select>
                </div>
                <div class="frmline1">
                    <label class="label2">
                        11. 保管期限：</label>
                    <select style="width: 100px" id="selBaoGuanQiXian" name="BaoGuanQiXian">
                        <option value="0">永久</option>
                        <option value="1">长期</option>
                        <option value="2">短期</option>
                    </select>
                </div>
                <div class="frmline1">
                    <label class="label2">
                        12. 状态：</label>
                    <select style="width: 100px" id="selZhuangTai" name="ZhuangTai">
                        <option value="0">原件</option>
                        <option value="1">复印件</option>
                        <option value="2">电子档</option>
                    </select>
                </div>
                <div class="frmline1">
                    <label class="label2">
                        13. 备注：</label>
                    <textarea class="inputbox" style="width: 450px; height: 80px" id="txtBeiZhu" name="BeiZhu"></textarea>
                </div>
                <!--Begin:[#14]-->
                <div class="frmline1" id="divAttachment" style="display: block;">
                    <label class="label2">
                        14. 附件：</label>
                    <input id="btnAttachment" onclick="OpenWinAttachment()" type="button" value="附件"
                        class="btnzc" style="width: 100px" />
                </div>
                <!--End:[#14]-->
            </th>
        </tr>
    </table>
    <table class="mytable" cellspacing="0" summary="菜单栏" style="width: 100%; margin-top: 5px;">
        <tr>
            <th scope="row" class="specalt">
                <input id="btnSave2" type="submit" value="保存文件" class="btnzc" style="width: 100px" />
                <input id="Button1" type="button" value="返回列表" class="btnzc" style="width: 100px"
                    onclick="back()" />
            </th>
        </tr>
    </table>
    </form>

    <script type="text/javascript">
        var fchkNewFile = null;
        var RqUrl = (gup('lb') == 'P') ? 'ajax/AddFile.aspx' : 'ajax/AddMFile.aspx';
        
        function back() {
            var tid = gup('tid');
            var eid = gup('eid');
            var rurl = (gup('lb') == 'P') ? 'mapfiles.aspx' : 'mgfiles.aspx'; /* P:项目类 M:管理类 */
            location.replace(rurl + '?tid=' + tid + '&eid=' + eid);
        }
        /* BEGIN: [#14] */
        window.addEvent('domready', function() {
            fchkNewFile = new FormCheck('frmNewFile');
            if (gup('id') != null)
            {
                RqUrl = (gup('lb') == 'P') ? 'ajax/UpdateFile.aspx?id=' + gup('id') : 'ajax/UpdateMFile.aspx?id=' + gup('id');
                $('btnSave1').value = '更新文件';
                $('btnSave2').value = '更新文件';
            }
            $('hidTid').value = gup('tid');
            $('hidEid').value = gup('eid');
            var id=gup('id');
            $("divAttachment").style.display=(id==null?"none":(id==""?"none":"block"));
        });
        /* BEGIN: [#14] */
        
        function submitForm() {
            var tid = gup('tid');
            var eid = gup('eid');
            var lb = gup('lb');
            var reqValues = new Request.HTML({ url: RqUrl,
                onSuccess: function(html) {
                    $('btnSave1').disabled = true;
                    $('btnSave2').disabled = true;
                    window.parent.$('mainPanel_iframe').src = window.parent.$('mainPanel_iframe').src;
                    alert(html.item(0).nodeValue);
                    if(lb == 'P' )
                    {
                        location.replace('mapfiles.aspx?eid=' + eid + '&tid=' + tid);
                    }
                    else if(lb == 'M')
                    {
                        location.replace('mgfiles.aspx?eid=' + eid + '&tid=' + tid);
                    }
                },
                onFailure: function() {
                    window.parent.MochaUI.notification('表单提交失败！'); ;
                }
            }).post($('frmNewFile'));
        }
         /* BEGIN: [#14] */
        function OpenWinAttachment()
        {
            new window.parent.MochaUI.Window({
                id: 'winNewAttachment',
                title: '上传附件管理',
                loadMethod: 'iframe',
                contentURL: 'Attachment.aspx?ProjType='+gup('lb')+'&FileType=F&id='+gup("id"),
                width: 600,
                height: 450,
                resizable:false
            });
        }
        /* BEGIN: [#14] */
         
        if(gup('id')!=null)
        {
            window.parent.MochaUI.notification('正在读取数据...');
        	
        	var lb = gup('lb');
            if(lb == 'P' )
            {
                var jsonRequest = new Request.JSON({url: "ajax/GetFile.aspx?" + (new Date()).getTime(), onComplete: function(person){
                setData(person.Moc_Files);
                }}).get({'id': gup('id'), 'status': 'update'});
            }
            else if(lb == 'M')
            {
                var jsonRequest = new Request.JSON({url: "ajax/GetMFile.aspx?" + (new Date()).getTime(), onComplete: function(person){
                setData(person.Moc_MFiles);
                }}).get({'id': gup('id'), 'status': 'update'});
            }
        }
    
    function setData(oData) {
        oData.each(function(dat) {
            $('txtMingCheng').value = dat.Name;
            $('txtWenJianHao').value = dat.WenJianHao;
            $('txtShenQingHao').value = dat.ShenQingHao;
            $('txtJueDingHao').value = dat.JueDingHao;

            var ChuTuRiQi = dat.FaWenRiQi;
            var JiShouRiQi = dat.JiShouRiQi;
            $('txtFaWenRiQi_Nian').value = ChuTuRiQi.substring(0, ChuTuRiQi.indexOf('-'));
            $('txtFaWenRiQi_Yue').value = ChuTuRiQi.substring(ChuTuRiQi.indexOf('-') + 1, ChuTuRiQi.lastIndexOf('-'));
            $('txtFaWenRiQi_Ri').value = ChuTuRiQi.substring(ChuTuRiQi.lastIndexOf('-') + 1, ChuTuRiQi.length);
            $('txtJieShouRiQi_Nian').value = JiShouRiQi.substring(0, JiShouRiQi.indexOf('-'));
            $('txtJieShouRiQi_Yue').value = JiShouRiQi.substring(JiShouRiQi.indexOf('-') + 1, JiShouRiQi.lastIndexOf('-'));
            $('txtJieShouRiQi_Ri').value = JiShouRiQi.substring(JiShouRiQi.lastIndexOf('-') + 1, JiShouRiQi.length);
            
            $('txtFaWenDanWei').value = dat.FaWenDanWei;
            $('txtShuLiang').value = dat.ShuLiang;
            $('selZaiTi').value = dat.ZaiTi;
            $('selCaiZhi').value = dat.CaiZhi;
            $('selMiJi').value = dat.MiJi;
            $('selBaoGuanQiXian').value = dat.BaoGuanQiXian;
            $('selZhuangTai').value = dat.ZhuangTai;
            //$('objBeizhu').value = dat.FaQiBuMen;
            //$('objXmtzqy').value = dat.YiJiaoRen;
            //$('objSgdw').value = dat.JiShouRen;
            $('txtBeiZhu').value = dat.BeiZhu;
            
            window.parent.MochaUI.notification('数据读取完毕...');
        });
    }
    </script>

</body>
</html>
